﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace BOGolf
{
    class admin
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _userid = -99;
        private string _username = "";
        private string _userpassword = "";
        private bool _isdeleted = false;
        
        public long userid
        {
            get
            {
                return _userid ;
            }
            set
            {
                _userid = value ;
            }
        }
        public string username
        {
             get
             {
                 return _username;
             }
            set
            {
                _username = value;
            }
        }
        public string userpassword
        {
            get
            {
                return _userpassword;
            }
            set
            {
                _userpassword = value;
            }
        }
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@userid",userid , DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@username", username, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@userpassword", userpassword, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3 };
                return DAC.Save("admin_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }

        public DataTable GetRecords(long userid, string username, string userpassword, bool isdeleted, string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@userid", userid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@username", username, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@userpassword", userpassword, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4 };
                DataTable dt1 = DAC.Select("admin_get", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
